package com.atguigu.springdemo.service;

import com.atguigu.springdemo.beans.Employee;
import com.atguigu.springdemo.dao.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/*          ①如果容器扫描到了@Service，自动在容器中，创建一个当前注解标识类的对象
 *  *       ②@Service给开发人员看，标识当前类是一个业务逻辑模型(服务)类*/
@Service
public class EmployeeServiceImp implements EmployeeService {
    //提供实现类实现Service接口
    //Service需要调Dao,在Service实现类中声明Dao属性
    @Autowired
    private EmployeeMapper empDao;

    @Override
    public Employee getEmployee(Integer id) {
        //检验输入的参数是否合法
        System.out.println("检查参数是否合法中...");
        //记录当前访问的信息到adult审计日志
        System.out.println("记录当前访问中");
        //查询员工,需要访问数据库,因此得有Dao
        Employee employee = empDao.getEmployee(id);
        //检验查询的emp是否合法
        System.out.println("检验查询的emp是否合法中");
        return employee;
    }

    @Override
    public void insertEmployee(Employee e) {
        empDao.insertEmployee(e);
    }

    @Override
    public void deleteEmployee(Integer id) {
        empDao.deleteEmployee(id);
    }

    @Override
    public void updateEmployee(Employee e) {
        empDao.updateEmployee(e);
    }

    @Override
    public List<Employee> selectAll() {
        return empDao.selectAll();
    }
}
